package cn.gson.springboot.model.service;

import cn.gson.springboot.model.dao.BusinesstripDao;
import cn.gson.springboot.model.mapper.BusinesstripMapper;
import cn.gson.springboot.model.pojos.Businesstrip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class BusinesstripService {
    @Autowired
    BusinesstripMapper busMapper;
    @Autowired
    BusinesstripDao busDao;

    public List<Businesstrip> selectBusiness(Integer deptId,Integer filter,Integer vague,String content){
        return  busMapper.selectBusiness(deptId,filter,vague,content);
    }

    public Businesstrip selectBusinessById(Integer businessId){
        return busMapper.selectBusinessById(businessId);
    }

    public List<Businesstrip> selectBusinessByOppId(Integer oppId){
        return busMapper.selectBusinessByOppId(oppId);
    }

    @Transactional(transactionManager = "transactionManager")
    public void saveBusiness(Businesstrip business){
        busDao.save(business);
    }

    @Transactional(transactionManager = "transactionManager")
    public void deleteBusiness(Integer businessId){
        busDao.deleteById(businessId);
    }
}
